package net.zjitc.controller.admin;
import net.zjitc.common.ResponseMessage;
import net.zjitc.pojo.Notice;
import net.zjitc.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;

/**
 * @Author admin
 * @Date 2019/4/1 8:32
 */
public class NoticeController {
    @Autowired
    NoticeService noticeService;



    @RequestMapping("/findAll")
    public String findAll(Model model){
        List<Notice> list = noticeService.findAll();
        model.addAttribute("list",list);
        return "/admin/notices/list.jsp";

    }

    @RequestMapping("/findById")
    public String findById(int id,Model model){
        Notice notice = noticeService.findById(id);
        model.addAttribute("notice",notice);
        return "/admin/notices/edit.jsp";
    }
/**
 * 修改的状态  ：成功-->修改成功
 *               失败-->修改失败
 *
 */

    @RequestMapping("/editNotice")
    public String editNotice(Notice notice,Model model){
        int resultCount = noticeService.updateById(notice);
        //响应成功
        if (resultCount>0){
            ResponseMessage responseMessage = new ResponseMessage();
        }
        //更新后应该显示列表
        return "redirect:/manage/notice/findAll";
    }
}
